<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>统计字符串中字符出现次数</title>
</head>

<body>

	<p> 统计字符串中字符出现次数</p>
	<p id="demo"></p>
	<script>

		function calStrNum(str) {
			var map = new Map();
			for (var i = 0; i < str.length; i++) {
				var c = str.charAt(i);
				if (map.has(c)) {
					var num = map.get(c);
					map.set(c, num + 1);
				} else {
					map.set(c, 1);
				}
			}

			console.log("adminmacmin")
			map.forEach((value, key) => {
				console.log("%s共出现了%s次", key, value)
			});
		}

		calStrNum("adminmacmin"	);
	</script>

</body>

</html>